﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace GameHungTrung.Entities
{
    class RoHungTrung  : MySprite2D
    {
        #region MY CODE
        public static int constTOP = 500;
        public static int constLEFT = 300;

        private int _iSpeed;
        private int _iLife;
        private int _iScores;

        private List<MySprite2D> _lstLifeImage;

        public RoHungTrung(Texture2D texture, int left, int top, int width, int height)
        {
            _textureSprite = texture;
            _iLeft = left;
            _iTop = top;
            _iWidth = width;
            _iHeight = height;

            _iSpeed = 15;
            _iLife = 3;
            _iScores = 0;
            KhoiTaoHinhRoNho();
        }
        //public RoHungTrung(ContentManager Content)
        //{
        //    _textureRo = Content.Load<Texture2D>(".\\images\\Ro");
        //    _iLeft = constLEFT;
        //    _iTop = constTOP;
        //    _iWidth = _textureRo.Width;
        //    _iHeight = _textureRo.Height;
        //    _iSpeed = 5;
        //    _Sprite = new MySprite2D(_textureRo, _iLeft, _iTop, _iWidth, _iHeight);
        //}

        public void KhoiTaoHinhRoNho()
        {
            _lstLifeImage = new List<MySprite2D>();
            for (int i = 0; i < _iLife; i++)
            {
                MySprite2D sp = new MySprite2D();
                sp.TEXTURESPRITE = GameManager.textureRoNho;
                sp.LEFT = 5 + i*50;
                sp.TOP = 10;
                sp.WIDTH = GameManager.textureRoNho.Width;
                sp.HEIGHT = GameManager.textureRoNho.Height;
                _lstLifeImage.Add(sp);
            }
        }

        public void VeHinhRoNho(SpriteBatch g)
        {
            for (int i = 0; i < _lstLifeImage.Count; i++)
            {
                _lstLifeImage[i].Draw(g);
            }
        }

        public void GiamMang()
        {
            if (_iLife > 0 && _lstLifeImage.Count > 0)
            {
                _iLife--;
                _lstLifeImage.RemoveAt(_lstLifeImage.Count - 1);
            }
        }

        public void TangMang()
        {
            if (_iLife > 0 && _iLife < 6)
            {
                _iLife++;
                MySprite2D sp = new MySprite2D();
                sp.TEXTURESPRITE = GameManager.textureRoNho;
                sp.LEFT = _lstLifeImage[_lstLifeImage.Count - 1].LEFT + 50;
                sp.TOP = 10;
                sp.WIDTH = GameManager.textureRoNho.Width;
                sp.HEIGHT = GameManager.textureRoNho.Height;
                _lstLifeImage.Add(sp);
            }
        }

        public void MoveLeft()
        {
            if (LEFT > 0)
            {
                LEFT -= SPEED;
            }
        }

        public void MoveRigth()
        {
            if (LEFT + WIDTH < Game1._iWidthWindow)
            {
                LEFT += SPEED;
            }
        }
        public int SPEED
        {
            get { return _iSpeed; }
            set { _iSpeed = value; }
        }
        public int ILife
        {
            get { return _iLife; }
            set { _iLife = value; }
        }
        public int IScores
        {
            get { return _iScores; }
            set { _iScores = value; }
        }
        #endregion
    }
}
